home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / IPFlakeWay / Squelch Module / source / myDNS.h < prev    next >
Text File  |  2000-06-23  |  3KB  |  103 lines

  1. // ===========================================================================
  2. //    myDNS.h            ©1999 Sustainable Softworks, All rights reserved.
  3. // ===========================================================================
  4. // dns protocol definitions
  5.  
  6. #ifndef _H_myDNS
  7. #define _H_myDNS
  8. #pragma once
  9.  
  10. // DNS header
  11. struct dns_header_t
  12.     {
  13.     UInt16    queryID;
  14.     UInt16    queryParameter;        // flags
  15.     UInt16    QDCount;            // questions
  16.     UInt16    ANCount;            // answer RRs
  17.     UInt16    NSCount;            // authority RRs
  18.     UInt16    ARCount;            // additional RRs
  19.     };
  20. typedef struct dns_header_t dns_header_t;
  21.  
  22. // DNS resource record
  23. struct dns_record_t
  24.     {
  25.     UInt16    rdType;
  26.     UInt16    rdClass;
  27.     UInt32    rdTTL;
  28.     UInt16    rdLength;
  29.     };
  30. typedef struct dns_record_t dns_record_t;
  31. // define size as a constant since the sizeof(dns_record_t)
  32. // can vary depending on alignment.
  33. const kdns_record_size = 10;
  34.  
  35. // dns UDP message
  36. typedef struct DNSMessage {
  37.     UInt8    op;                    // operation (1=request, 2=reply)
  38. } DNSMessage_t;
  39.  
  40. const kDNSResponseReady        = 1;
  41.  
  42.  
  43.  
  44. // Query Types
  45. const UInt16 kQTypeA                = 1;
  46. const UInt16 kQTypeCNAME            = 5;
  47. const UInt16 kQTypeHINFO            = 13;        // Host info (CPU & OS)
  48. const UInt16 kQTypeMINFO            = 14;        // Mailbox Info
  49. const UInt16 kQTypeMX                = 15;        // Mail Exchanger
  50. const UInt16 kQTypeNS                = 2;        // Authoritative Name Server
  51. const UInt16 kQTypePTR                = 12;
  52. const UInt16 kQTypeSOA                = 6;
  53. const UInt16 kQTypeTXT                = 16;
  54. const UInt16 kQTypeAAAA                = 28;        // IP6 Address
  55. const UInt16 kQTypeAXFR                = 252;        // Zone Transfer
  56. const UInt16 kQTypeALL                = 255;        // All Resource Records
  57. const UInt16 kQTypePrivate            = 256;
  58. //const UInt16 kQTypeLS                = kQTypePrivate + 1;    // List Domains
  59.  
  60. // Query Type hash values
  61. //    Hash query types as the sum of octets in the corresponding PString.
  62. //    Hash values are used to compare the query type in a GURL string.
  63. const UInt16 kHashA                    = 1 + 'A'; 
  64. const UInt16 kHashCNAME                = 5 + 'C' + 'N' + 'A' + 'M' + 'E'; 
  65. const UInt16 kHashHINFO                = 5 + 'H' + 'I' + 'N' + 'F' + 'O'; 
  66. const UInt16 kHashMINFO                = 5 + 'M' + 'I' + 'N' + 'F' + 'O'; 
  67. const UInt16 kHashMX                = 2 + 'M' + 'X'; 
  68. const UInt16 kHashNS                = 2 + 'N' + 'S';
  69. const UInt16 kHashPTR                = 3 + 'P' + 'T' + 'R';
  70. const UInt16 kHashSOA                = 3 + 'S' + 'O' + 'A';
  71. const UInt16 kHashTXT                = 3 + 'T' + 'X' + 'T';
  72. const UInt16 kHashAAAA                = 4 + 'A' + 'A' + 'A' + 'A'; 
  73. const UInt16 kHashAXFR                = 4 + 'A' + 'X' + 'F' + 'R';  
  74. const UInt16 kHashALL                = 1 + ('*' & 0xDF); 
  75. const UInt16 kHashLS                = 2 + 'L' + 'S';
  76.  
  77. // Query Class
  78. const UInt16 kQClassIN                = 1;
  79.  
  80. // Query Code masks
  81. //                                 1  1  1  1  1  1
  82. //   0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
  83. // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  84. // |QR|   Opcode  |AA|TC|RD|RA|   Z    |   RCODE   |
  85. // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  86. const UInt16 kQueryMaskQR            = 0x8000;
  87. const UInt16 kQueryMaskOPCODE        = 0x7800;
  88. const UInt16 kQueryMaskAA            = 0x0400;
  89. const UInt16 kQueryMaskTC            = 0x0200;
  90. const UInt16 kQueryMaskRD            = 0x0100;
  91. const UInt16 kQueryMaskRA            = 0x0080;
  92. const UInt16 kQueryMaskRCODE        = 0x000F;
  93.  
  94. // Default Column positions
  95. const kDNSColumn1                        = 4;
  96. const kDNSColumn2                        = 30;
  97. const kDNSColumn3                        = 36;
  98. const kDNSColumn4                        = 44;
  99. const kDNSColumn5                        = 66;
  100.  
  101. const kNSLookupText                    = 244;    // resource ID for col pos
  102.  
  103. #endif